﻿namespace ServerRPG
{
    static class CommandParser
    {
        private static string _separator = "|";
        public static string Separator { set { _separator = value; } get { return _separator; } }

        public static string GetCommand(string msg, int commandNumber)
        {
            string command = Check(msg);
            if (command != string.Empty)
                return command;

            if (msg == string.Empty)
                return string.Empty;

            /*if (!msg.Contains(_separator))
                return string.Empty;*/

            string[] commands = msg.Split(new char[] { _separator[0] });
            if (commands[commandNumber] == string.Empty)
                return string.Empty;

            return commands[commandNumber];
        }

        private static string Check(string msg)
        {
            if (!msg.Contains(_separator))
                return string.Empty;


            if (msg.IndexOf(_separator) == 0)
                return string.Empty;
            
            return string.Empty;
        }
    }
}
